package logic

import (
	"context"
	"encoding/json"

	"diff.wang/asynqsrv/common"
	"github.com/hibiken/asynq"
	"github.com/zeromicro/go-zero/core/logx"
)

type ComputerAddTask struct {
}

func NewComputerAddTask() *ComputerAddTask {
	return &ComputerAddTask{}
}

func (caj *ComputerAddTask) ProcessTask(ctx context.Context, t *asynq.Task) error {

	var p common.ComputerAddPayload
	if err := json.Unmarshal(t.Payload(), &p); err != nil {
		return err
	}
	logx.Info("%s gets processed successfully by a worker,taskId: %v\n", common.ScheduleComputerAdd, t.ResultWriter().TaskID())
	return nil
}
